package com.robot.web;

import javax.faces.event.ActionEvent;

import org.primefaces.context.RequestContext;

public class Actuator {

	String letra[] = new String[1];

	public void controlarTeclado(ActionEvent actionEvent) {
		RequestContext context = RequestContext.getCurrentInstance();
		System.out.println("control por teclado ");
		context.addCallbackParam("view", "control_teclado.xhtml");
	}

	public void controlarPorVoz(ActionEvent actionEvent) {
		RequestContext context = RequestContext.getCurrentInstance();
		System.out.println("control por Voz ");
		context.addCallbackParam("view", "control_voz.xhtml");
	}

	public void irAdelante() {
		System.out.println("irAdelante");
		letra[0] += "u";
		try {
			(new EnvioSerial()).transmision(letra[0]);
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}

	public void irAtras() {
		System.out.println("irAtras");
		letra[0] += "d";
		try {
			(new EnvioSerial()).transmision(letra[0]);
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}

	}

	public void irIzquierda() {
		System.out.println("irIzquierda");
		letra[0] += "l";
		try {
			(new EnvioSerial()).transmision(letra[0]);
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}

	}

	public void irDerecha() {
		System.out.println("irDerecha");
		letra[0] += "r";
		try {
			(new EnvioSerial()).transmision(letra[0]);
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}

	}

	public void detener() {
		System.out.println("irDerecha");
		letra[0] += "s";
		try {
			(new EnvioSerial()).transmision(letra[0]);
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}

	}

}
